package atguigu;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

public class ListUtil {

    public static void main(String[] args) {
//        List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9);
//        // ArrayList<Object> newArrayList = Lists.newArrayList();
//        List<List<Integer>> partition = Lists.partition(lst, 3);
//        // System.out.println(partition.size());
//        partition.stream().forEach(l -> {
//            l.forEach(a -> {
//                System.out.println(a);
//            });
//        });
//        
//        List<Integer> asList = Arrays.asList(1,3,4,5);
        
//        
//        String str = "168.0";
//        int index = str.indexOf(".");
//        System.out.println(index);
//        str = str.substring(0, index);
//        System.out.println(str);
//        int parseInt = Integer.parseInt(str);
//        System.out.println(parseInt);
        
        
//        Map<String, Long> map = new HashMap<String, Long>();
//		map.put("c", 33333L);
//		map.put("a", 11111L);
//		map.put("d", 44444L);
//		map.put("e", 55555L);
//		map.put("b", 22222L);
//		
//		//��map.entrySet()ת����list
//		List<Map.Entry<String, Long>> list = new ArrayList<Map.Entry<String, Long>>(map.entrySet());
//		Collections.sort(list, new Comparator<Map.Entry<String, Long>>() {
//			//��������
//			@Override
//			public int compare(Entry<String, Long> o1, Entry<String, Long> o2) {
//				//return o1.getValue().compareTo(o2.getValue());
//				return o2.getValue().compareTo(o1.getValue());
//			}
//		});
// 
//		for (Map.Entry<String, Long> mapping : list) {
//			System.out.println(mapping.getKey() + ":" + mapping.getValue());
//		}
    	
    	
    	ModelUseRate mUseRate = new ModelUseRate("型号2", 11.5);
    	ModelUseRate mUseRate2 = new ModelUseRate("型号3", 18.5);
    	ModelUseRate mUseRate3 = new ModelUseRate("型号1", 12.5);
    	ModelUseRate mUseRate4 = new ModelUseRate("型号4", 13.5);
    	ModelUseRate mUseRate5 = new ModelUseRate("型号5", 22.5);
    	ModelUseRate mUseRate6 = new ModelUseRate("型号9", 52.5);
    	ModelUseRate mUseRate7 = new ModelUseRate("型号8", 2.5);
    	ModelUseRate mUseRate8 = new ModelUseRate("型号21", 72.5);
    	ModelUseRate mUseRate9 = new ModelUseRate("型号31", 222.5);
    	ModelUseRate mUseRate10 = new ModelUseRate("型号41", 122.5);
    	ModelUseRate mUseRate11 = new ModelUseRate("型号71", 172.5);
    	
    	List<ModelUseRate> list = new ArrayList<ModelUseRate>();
    	list.add(mUseRate2);
    	list.add(mUseRate3);
    	list.add(mUseRate4);
    	list.add(mUseRate5);
    	list.add(mUseRate6);
    	list.add(mUseRate7);
    	list.add(mUseRate8);
    	list.add(mUseRate9);
    	list.add(mUseRate10);
    	list.add(mUseRate11);

    	
    	Collections.sort(list, new Comparator<ModelUseRate>() {

			@Override
			public int compare(ModelUseRate o1, ModelUseRate o2) {
				return o2.getRate().compareTo(o1.getRate());
			}
		});
    	
    	System.out.println(list);
    	
    	int size = list.stream().filter(e->e.getRate()>500.0).collect(Collectors.toList()).size();
    	System.out.println(size);
    	
    	for (int i = 0; i < 5; i++) {
			System.out.println(list.get(i));
		}
    }
}